﻿using IBLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace WebAPI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class weController : ControllerBase
    {
        public weController(Iuserbll bll,ILogger<weController> logger)
        {
            Bll = bll;
            Logger = logger;
        }

        public Iuserbll Bll { get; }
        public ILogger<weController> Logger { get; }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost("add")]
        public Task<int> add(user user)
        {
            try
            {
                Logger.LogInformation("添加成功");
                return Bll.add(user);
            }
            catch (Exception)
            {

                throw;
            }
           
        }
        /// <summary>
        /// 房号查询
        /// </summary>
        /// <returns></returns>
        [HttpGet("fhxs")]
        public dynamic fhxs()
        {
            try
            {
                return Bll.fhxs();

            }
            catch (Exception)
            {

                throw;
            }
          
        }
        /// <summary>
        /// 房型查询
        /// </summary>
        /// <returns></returns>
        [HttpGet("fxxs")]


        public dynamic fxxs()
        {
            try
            {
                return Bll.fxxs();
            }
            catch (Exception)
            {

                throw;
            }
           
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="zh"></param>
        /// <param name="mm"></param>
        /// <returns></returns>
        [HttpGet("login")]

        public int login(string zh, string mm)
        {
            return Bll.login(zh, mm);  
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost("update")]
        public Task<int> update(user user)
        {
            return Bll.update(user);
        }
        /// <summary>
        /// 详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("xq")]
        public dynamic xq(int id)
        {
            return Bll.xq(id);
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="fhid"></param>
        /// <param name="fxid"></param>
        /// <returns></returns>
        [HttpGet("xs")]
        public dynamic xs(int? fhid, int? fxid)
        {
            return Bll.xs(fhid, fxid);
        }
    }
}
